added samples
[windows-sources.git] / sdk / samples / all in on code / Visual Studio 2008 / CSVSPackageAddReferenceTab / ProvideReferencePageAttribute.cs
blobf7a11cad10d213029319cd5f427e9c47802c8bd6
1 /****************************** Module Header ******************************\
2 * Module Name: ProvideReferencePageAttribute.cs
3 * Project: CSVSPackageAddReferenceTab
4 * Copyright (c) Microsoft Corporation.
5 *
6 * Visual Studio supports to extend the Add Reference dialog and add custom
7 * tab page into the dialog.
9 * This sample demostrate you how to add a custom .NET user control as a tab
10 * page into the add reference dialog, and how to enable select button and
11 * handle item selection events.
13 * All the sample code is based on MPF.
15 * The sample is initiated by the thread on the forum:
16 * http://social.msdn.microsoft.com/Forums/en-US/vsx/thread/ddb0f935-b8ac-400d-9e3d-64d74be85031
18 * History:
19 * * 1/12/2010 1:00 AM Hongye Sun Created
20 \***************************************************************************/
22 using System;
23 using System.Collections.Generic;
24 using System.Linq;
25 using System.Text;
26 using Microsoft.VisualStudio.Shell;
27 using Microsoft.VisualStudio.Shell.Interop;
29 namespace Microsoft.CSVSPackageAddReferenceTab
31 [AttributeUsage(AttributeTargets.Class, AllowMultiple=true, Inherited=true)]
32 public class ProvideReferencePageAttribute : RegistrationAttribute
35 private Guid pageGuid;
36 private Guid packageGuid;
37 private string pageRegKey;
39 public ProvideReferencePageAttribute(
40 Type pageType,
41 Type packageType,
42 string name)
44 this.pageGuid = pageType.GUID;
45 this.packageGuid = packageType.GUID;
46 this.pageRegKey = @"ComponentPickerPages\" + name; ;
49 public override void Register(RegistrationAttribute.RegistrationContext context)
51 using (Key pageKey = context.CreateKey(pageRegKey))
53 pageKey.SetValue(string.Empty, string.Empty);
54 pageKey.SetValue("AddToMru", 1);
55 pageKey.SetValue("ComponentType", ".NET Assembly");
56 pageKey.SetValue("Package", packageGuid.ToString("B"));
57 pageKey.SetValue("Page", pageGuid.ToString("B"));
58 pageKey.SetValue("Sort", 0x35);
62 public override void Unregister(RegistrationAttribute.RegistrationContext context)
64 context.RemoveKey(pageRegKey);